<%@page import="java.util.*, java.sql.*, javax.sql.DataSource, javax.naming.InitialContext, com.cpimex.eprice.action.plugin.ConnectionBuilder"%>
<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>
<%
	final String SUBSEG = "cod_subseg";	

	String str_cod_subseg = request.getParameter(SUBSEG);
	 
	String str_division = "null";
	
	InitialContext context = new InitialContext();
	//DataSource dataSrc = (DataSource) context.lookup("java:comp/env/jdbc/Eprice");
	Connection conn = ConnectionBuilder.epriceConnection(context);
	Statement stmt = conn.createStatement();
	
	try{
		String  str_query = 
			" SELECT cod_division " +
			" FROM ep_subseg_division WHERE (cod_subseg <> '' " +
			"      AND cod_subseg IS NOT NULL " +
			"      AND cod_subseg = '"+(str_cod_subseg==null?"0000":str_cod_subseg)+"') ";
		ResultSet rs = stmt.executeQuery(str_query);
		
		if(rs.next()){
			str_division =  rs.getString("cod_division");
		}
		out.println(str_division);
	}catch(Exception ex){
		ex.printStackTrace();
	}finally{
		conn.close();
	}

%>